package com.one.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.one.dto.SupervisorPageRequestDTO;
import com.one.entity.Supervisor;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface SupervisorMapper extends BaseMapper<Supervisor> {
    /*
    * 根据手机号获取监督员信息
    * */
    @Select("SELECT * FROM supervisor WHERE tel_id = #{telId}")
    Supervisor getByTelId(String telId);

    /*
    * 添加监督员信息
    * */
    @Insert("INSERT INTO supervisor (tel_id, password, real_name, birthday,sex) " +
            "VALUES (#{telId}, #{password}, #{realName}, #{birthday},#{sex})")
    int saveSupervisor(Supervisor supervisor);

    @Update("UPDATE supervisor SET password=#{password} WHERE tel_id=#{telId}")
    void updatePasswordByTelId(Supervisor supervisor);

    /**
     * 分页查询监督员列表
     * @param request 包含查询条件和分页参数的请求DTO
     * @return 监督员列表
     */
    List<Supervisor> listSupervisors(SupervisorPageRequestDTO request);

    int updateBytelId(Supervisor supervisor);

    int countSupervisors(SupervisorPageRequestDTO request);
}
